package com.woniuxy.consumer;

import com.woniuxy.config.RedisConfig;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;
@Component
@RocketMQMessageListener(consumerGroup = "woniu_user",topic = "woniu")
public class CodeConsumer implements RocketMQListener<String> {
    @Autowired
    private RedisConfig redisConfig;
    @Override
    public void onMessage(String tel) {
        String psw = "";
        for(int i=0;i<6;i++){
            psw += String.valueOf((int)(Math.random()*10));
        }
        System.out.println(psw);
        redisConfig.opsForValue().set(tel,psw,30, TimeUnit.SECONDS);
    }
}
